package mil.af.amc.adpetracker.web.actions.struts2.manufacturer;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;
import com.opensymphony.xwork2.Preparable;
import mil.af.amc.adpetracker.model.Manufacturer;
import mil.af.amc.adpetracker.service.ManufacturerService;
import org.apache.struts2.convention.annotation.Namespace;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
 * Struts 2 Action for manufacturer actions
 *
 * @author Jason Ferguson
 */
@Namespace("manufacturer")
public class ManufacturerAction extends ActionSupport implements ModelDriven<Manufacturer>, Preparable {

    @Autowired
    private ManufacturerService manufacturerService;

    // ModelDriven implementation

    private Manufacturer model;

    public Manufacturer getModel() {
        return model;
    }

    private List<Manufacturer> manufacturerList;

    public void prepare() throws Exception {

    }

    public void prepareExecute() throws Exception {
        manufacturerList = manufacturerService.getAll();
    }


    /**
     * Return the view containing the list of all Manufacturers
     *
     * @return
     * @throws Exception
     */
    public String execute() throws Exception {
        return SUCCESS;

    }

    /**
     * Return the view for creating a new manufacturer
     *
     * @return
     * @throws Exception
     */
    public String viewCreate() throws Exception {
        throw new UnsupportedOperationException();
    }

    /**
     * Create a new manufacturer
     *
     * @return
     * @throws Exception
     */
    public String create() throws Exception {
        throw new UnsupportedOperationException();
    }
}
